package com.yxinsur.imc.web.controller.business;

import com.yxinsur.imc.business.form.InsSchemeForm;
import com.yxinsur.imc.business.service.IImcInsSchemeService;
import com.yxinsur.imc.business.vo.InsSchemeVo;
import com.yxinsur.imc.business.vo.select.SelectInsScheme;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 我的保险产品库(险种)Controller
 * 
 * @author imc
 * @date 2021-05-10
 */
@Api(value="险种方案接口服务",tags={"4.3.险种方案接口服务"})
@RestController
@RequestMapping("/business/ins/scheme")
public class ImcInsSchemeController extends BaseController
{
    @Autowired
    private IImcInsSchemeService imcInsSchemeService;

    /**
     * 查询险种方案列表
     */
    @ApiOperation("险种方案分页数据查询")
    @GetMapping("/list/{repoInsId}")
    public TableDataInfo list(InsSchemeForm insSchemeForm,@PathVariable Long repoInsId)
    {
        startPage();
        insSchemeForm.setRepoInsId(repoInsId);
        List<InsSchemeVo> list = imcInsSchemeService.selectImcInsSchemeList(insSchemeForm);
        return getDataTable(list);
    }
    /**
     * 新增险种方案
     */
    @ApiOperation("险种方案-新增")
    @PostMapping
    public AjaxResult add(@RequestBody InsSchemeForm insSchemeForm)
    {
        return toAjax(imcInsSchemeService.insertImcInsScheme(insSchemeForm));
    }

    /**
     * 修改险种方案
     */
    @ApiOperation("险种方案-更新")
    @PutMapping
    public AjaxResult edit(@RequestBody InsSchemeForm insSchemeForm)
    {
        return toAjax(imcInsSchemeService.updateImcInsScheme(insSchemeForm));
    }
    @ApiOperation("险种方案删除")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(imcInsSchemeService.deleteInsSchemeByIds(ids));
    }

    /**
     * 获取方案下拉列表
     */
    @ApiOperation("获取方案下拉列表")
    @PostMapping("/select/{repoInsId}")
    public List<SelectInsScheme> selectDataList(@PathVariable Long repoInsId)
    {
        return this.imcInsSchemeService.selectDataList(repoInsId);
    }
}
